﻿Imports System.Data
Imports System.Data.SqlClient

Public Class Proyectos

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Main.WindowState = FormWindowState.Normal
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox7.Text = "" Or TextBox8.Text = "" Or TextBox9.Text = "" Or TextBox10.Text = "" Or TextBox11.Text = "" Or TextBox12.Text = "" Or TextBox13.Text = "" Or TextBox15.Text = "" Or TextBox14.Text = "" Or TextBox16.Text = "" Or TextBox17.Text = "" Or TextBox18.Text = "" Or TextBox19.Text = "" Or TextBox21.Text = "" Or TextBox22.Text = "" Or TextBox23.Text = "" Or ComboBox1.Text = "" Or RichTextBox1.Text = "" Then
            MsgBox("No pueden haber campos vacios!", MsgBoxStyle.Information, "Atencion")
        Else
            Try
                Dim strCon As String = "Data Source=(local)\SQLEXPRESS ;Initial Catalog=cegan ;Integrated Security=True"
                Dim sql As String = "insert into proyecto values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & ComboBox1.Text & "','" & TextBox4.Text & "-" & TextBox5.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "');"
                Dim tabla As New DataTable
                Dim adaptador As New SqlDataAdapter(sql, strCon)
                adaptador.Fill(tabla)

                Dim strCon2 As String = "Data Source=(local)\SQLEXPRESS ;Initial Catalog=cegan ;Integrated Security=True"
                Dim sql2 As String = "insert into obra values ('" & TextBox7.Text & "','" & TextBox15.Text & "','" & TextBox16.Text & "','" & TextBox19.Text & "-" & TextBox18.Text & "');"
                Dim tabla2 As New DataTable
                Dim adaptador2 As New SqlDataAdapter(sql2, strCon2)
                adaptador2.Fill(tabla2)

                Dim strCon3 As String = "Data Source=(local)\SQLEXPRESS ;Initial Catalog=cegan ;Integrated Security=True"
                Dim sql3 As String = "insert into orden_bodega values ('" & TextBox8.Text & "','" & TextBox1.Text & "','" & RichTextBox1.Text & "');"
                Dim tabla3 As New DataTable
                Dim adaptador3 As New SqlDataAdapter(sql3, strCon3)
                adaptador3.Fill(tabla3)

                Dim strCon4 As String = "Data Source=(local)\SQLEXPRESS ;Initial Catalog=cegan ;Integrated Security=True"
                Dim sql4 As String = "insert into constructora values ('" & TextBox3.Text & "-" & TextBox17.Text & "','" & TextBox11.Text & "','" & TextBox12.Text & "','" & TextBox13.Text & "','" & TextBox14.Text & "');"
                Dim tabla4 As New DataTable
                Dim adaptador4 As New SqlDataAdapter(sql4, strCon4)
                adaptador4.Fill(tabla4)


                Dim strCon5 As String = "Data Source=(local)\SQLEXPRESS ;Initial Catalog=cegan ;Integrated Security=True"
                Dim sql5 As String = "insert into contacto values ('" & TextBox19.Text & "-" & TextBox18.Text & "','" & TextBox21.Text & "','" & TextBox22.Text & "','" & TextBox23.Text & "','" & TextBox3.Text & "-" & TextBox17.Text & "');"
                Dim tabla5 As New DataTable
                Dim adaptador5 As New SqlDataAdapter(sql5, strCon5)
                adaptador5.Fill(tabla5)



                MsgBox("Datos guardados con exito", MsgBoxStyle.Information, "OK")
                TextBox1.Text = ""
                TextBox2.Text = ""
                TextBox3.Text = ""
                TextBox4.Text = ""
                TextBox5.Text = ""
                TextBox6.Text = ""
                TextBox7.Text = ""
                TextBox8.Text = ""
                TextBox9.Text = ""
                TextBox10.Text = ""
                TextBox11.Text = ""
                TextBox12.Text = ""
                TextBox13.Text = ""
                TextBox15.Text = ""
                TextBox14.Text = ""
                TextBox16.Text = ""
                TextBox17.Text = ""
                TextBox18.Text = ""
                TextBox19.Text = ""
                TextBox21.Text = ""
                TextBox22.Text = ""
                TextBox23.Text = ""
                ComboBox1.Text = ""
                RichTextBox1.Text = ""
            Catch ex As Exception
                MsgBox("error en los datos", MsgBoxStyle.Critical, "Error")

            End Try

        End If

    End Sub


End Class